package com.fast.log.mq.consumer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import com.fast.common.constants.MQConst;
import com.fast.log.entity.SysLog;
import com.fast.log.mapper.SysLogMapper;

@Component
public class SysLogQueueReceive {
	
	private Logger logger = LoggerFactory.getLogger(SysLogQueueReceive.class);
	
	@Autowired
	private SysLogMapper mapper ;
	
	@JmsListener(destination=MQConst.SYS_LOG_QUEUE)
	public void receive(SysLog entity) {
		this.mapper.insertSelective(entity);
		logger.info("系统日志[日志类型：{}, 操作描述：{}, 类名：{}, 方法：{}, 参数：{}, IP：{}, 详情：{}, URI：{}, 异常：{}]", 
				entity.getType(),
				entity.getDescription(), entity.getClassName(), entity.getMethodName(), 
				entity.getParams(), entity.getIp(), entity.getDetail(), entity.getUri(), entity.getException());
	}

}
